<template>
  <div class="sidebar">
    <el-menu :default-active="$route.path" background-color="#545c64" text-color="#fff" unique-opened router>
      <template v-for="(item,index) in currentMenus">
        <template v-if="item.hasSublist">
          <el-submenu :index="item.index" :key="index">
            <template slot="title">{{ item.name }}</template>
            <el-menu-item v-for="(subItem,i) in item.list" :key="i" :index="subItem.index">
              {{ subItem.name }}
            </el-menu-item>
          </el-submenu>
        </template>
        <template v-else>
          <el-menu-item v-if="item.index.indexOf('home') > -1" :key="index" :index="item.index">
            {{ item.name }}
          </el-menu-item>
        </template>
      </template>
    </el-menu>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapGetters(["currentMenus", "token"]),
    onRoutes() {
      return this.$route.path;
    }
  }
};
</script>

<style scoped>
.sidebar {
  display: block;
  position: absolute;
  width: 235px;
  left: 0;
  top: 60px;
  bottom: 0;
  background: #2e363f;
}

.sidebar > ul {
  height: 100%;
}

.copyright {
  position: absolute;
  bottom: 30px;
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: normal;
  width: 100%;
  font-weight: 300;
  line-height: 20px;
  margin: 0;
}
</style>
